# -*- mode: python ; coding: utf-8 -*-

import os
import sys

block_cipher = None

a = Analysis(
    ['main.py'],
    pathex=[],
    binaries=[],
    datas=[
        ('src/locales', 'src/locales'),
        ('assets/icon.png', 'assets') if os.path.exists('assets/icon.png') else None,
        ('assets/icon.ico', '.') if os.path.exists('assets/icon.ico') else None,
    ],
    hiddenimports=[],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    win_no_prefer_redirects=False,
    win_private_assemblies=False,
    cipher=block_cipher,
    noarchive=False,
)

pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
    pyz,
    a.scripts,
    [],
    exclude_binaries=True,
    name='{{APP_NAME}}',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    console={{CONSOLE}},
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
    icon='{{ICON_PATH}}' if '{{ICON_PATH}}' else None,
)

coll = COLLECT(
    exe,
    a.binaries,
    a.zipfiles,
    a.datas,
    strip=False,
    upx=True,
    upx_exclude=[],
    name='{{APP_NAME}}',
)

# macOS 应用配置
if sys.platform == 'darwin':
    app = BUNDLE(
        coll,
        name='{{APP_NAME}}.app',
        icon='{{ICON_PATH}}' if '{{ICON_PATH}}' else None,
        bundle_identifier='com.audioeditor.{{APP_BUNDLE_ID}}',
        version='{{APP_VERSION}}',
        info_plist={
            'CFBundleName': '{{APP_NAME}}',
            'CFBundleDisplayName': '{{APP_NAME}}',
            'CFBundleShortVersionString': '{{APP_VERSION}}',
            'CFBundleVersion': '{{APP_VERSION}}',
            'CFBundleIdentifier': 'com.audioeditor.{{APP_BUNDLE_ID}}',
            'NSHumanReadableCopyright': 'Copyright © 2024 {{APP_AUTHOR}}',
            'CFBundleDevelopmentRegion': 'zh_CN',
            'LSApplicationCategoryType': 'public.app-category.music',
            'NSHighResolutionCapable': True,
        },
    )